
#ifndef __LIBSSH2_INTERFACE_H
#define __LIBSSH2_INTERFACE_H

#include <libssh2.h>
#include "../iface/debug.h"

/** An interface encapsulating functions to do with the libssh2
 * library. */
class LibSSH2Interface
{
   public:
      static void destroyInstance();
      static LibSSH2Interface &getInstance();
      ~LibSSH2Interface();
      static void func_CheckLibSSH2Error(const char *servername, int serverport, int localconnport, int status, const char *fpretty, int line);
      static void func_CheckLastLibSSH2Error(const char *servername, int serverport, int localconnport, LIBSSH2_SESSION *tsession, const char *fpretty, int line);
   private:
      LibSSH2Interface();
      /** Private pointer to hold the singleton instance. */
      static LibSSH2Interface *libssh2_iface_singleton;
};

#define CheckLibSSH2Error(n,p,l,s) LibSSH2Interface::func_CheckLibSSH2Error(n,p,l,s, __PRETTY_FUNCTION__, __LINE__)
#define tCheckLibSSH2Error(s) LibSSH2Interface::func_CheckLibSSH2Error(realservername, realserverport, localconnserverport, s, __PRETTY_FUNCTION__, __LINE__)
#define elCheckLibSSH2Error(kthis) LibSSH2Interface::func_CheckLastLibSSH2Error((kthis)->getRealServerName(), (kthis)->getRealServerPort(), (kthis)->getLocalConnServerPort(), (LIBSSH2_SESSION *)((kthis)->getSSHSession()), __PRETTY_FUNCTION__, __LINE__)
#define eCheckLibSSH2Error(kthis,s) LibSSH2Interface::func_CheckLibSSH2Error((kthis)->getRealServerName(), (kthis)->getRealServerPort(), (kthis)->getLocalConnServerPort(), s, __PRETTY_FUNCTION__, __LINE__)

#endif
